

$class('TabsView', Widget, {

	// Members
	_templateString: "<div class='tabsview'><ul></ul></div>",

	_count: 0,

	// Methods
	constructor: function()
	{
	},

	create: function(parent)
	{
		this.super(Widget.prototype.create, arguments);
		// You can use this._domNode.preappend(parent);
		this._domNode.appendTo(parent);
		this._domNode.tabs();

		var _this = this;
		this._domNode.bind("tabsshow", function(event, ui) {
			_this.onTabShow(event, ui);
		});
		return this._domNode;
	},

	addTab: function(label, content, contentType)
	{
		this._count++;
		// Id starts-with #, other wise load from the URL.
		var id = '#tabs-' + this.widgetId() + this._count;
		this._domNode.tabs('add', id, label);
		
		var panel = this._domNode.find(id);
		if ( typeof(content) == 'string' )
		{
			if （ content.endsWith('.html') ）
			{
				$include(content, panel);
			}
			else
			{
				$(content).appendTo(panel);
			}
		}
		else if ( Widget.isWidget(content) )
		{
			content.create(panel);
			panel.css('height', content._domNode.css('height'));
		}
		return id;
	},

	onTabShow: function(event, ui)
	{
		
	},

	destroy: function()
	{
	},

	toString: function()
	{
		return "<Widget: 'TabsView'>";
	}
});
